package com.cloudkinto.controller.workOrder.type;


import com.cloudkinto.base.BaseController;
import com.cloudkinto.bo.workOrder.type.WorkOrderTypeAddBo;
import com.cloudkinto.bo.workOrder.type.WorkOrderTypeQueryBo;
import com.cloudkinto.bo.workOrder.type.WorkOrderTypeUpdateBo;
import com.cloudkinto.common.annotations.UserSessionRequired;
import com.cloudkinto.common.web.SingleResult;
import com.cloudkinto.service.workOrder.WorkOrderTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 工单类型 前端控制器
 * </p>
 *
 * @author long
 * @since 2025-01-07
 */
@RestController
@RequiredArgsConstructor
@Api(tags = "wms工单类型模块")
@RequestMapping("/api/admin/wms/workOrderType")
public class WorkOrderTypeWmsController extends BaseController {

    private final WorkOrderTypeService workOrderTypeService;

    @UserSessionRequired
    @PostMapping
    @ApiOperation(value = "工单类型新增", notes = "工单类型新增")
    public SingleResult add(@RequestBody @Validated WorkOrderTypeAddBo req) {
        return SingleResult.success("新增成功", workOrderTypeService.add(req));
    }

    @UserSessionRequired
    @PutMapping
    @ApiOperation(value = "工单类型修改", notes = "工单类型修改")
    public SingleResult update(@RequestBody @Validated WorkOrderTypeUpdateBo req) {
        return SingleResult.success("修改成功", workOrderTypeService.update(req));
    }

    @UserSessionRequired
    @PutMapping("/updateEnable/{id}")
    @ApiOperation(value = "工单类型停用启用", notes = "工单类型停用启用")
    public SingleResult updateEnable(@PathVariable("id") Long id) {
        return SingleResult.success("修改成功", workOrderTypeService.updateEnable(id));
    }

    @UserSessionRequired
    @GetMapping("/list")
    @ApiOperation(value = "工单类型查询", notes = "工单类型查询")
    public SingleResult list() {
        WorkOrderTypeQueryBo bo = new WorkOrderTypeQueryBo();
        bo.setTenantId(getTenantId());
        return SingleResult.success("查询成功", workOrderTypeService.getList(bo));
    }
}

